from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField
# Create your models here.

#Классы для хранения вопросов
class question(models.Model):
    titel = models.CharField('Заголовок',max_length=100, blank=False, null=True)
    question = RichTextUploadingField(blank=True, null=True, verbose_name='Вопрос')
    name = models.CharField('Имя',max_length=100, blank=False, null=True)
    id = models.BigAutoField

    def __str__(self):
        return str(self.id)
    
    class Meta:
        verbose_name = 'Вопрос'
        verbose_name_plural  =  'Вопросы'

#class questionImage(models.Model):
#    image = models.ImageField(upload_to='questionImage/%id/', blank=True, null=True)
#    question = models.ForeignKey(question, related_name="images", on_delete=models.CASCADE)

#Классы для хранения ответов
class answer(models.Model):
    name = models.CharField('Имя',max_length=100, blank=False, null=True)
    answer = RichTextUploadingField(blank=True, null=True, verbose_name='Ответ')
    question = models.ForeignKey(question, related_name="answers", on_delete=models.CASCADE)
    
    id = models.BigAutoField

    def __str__(self):
        return str(self.id)
    
    class Meta:
        verbose_name = 'Ответ'
        verbose_name_plural  =  'Ответы'

#class answerImage(models.Model):
#    image = models.ImageField(upload_to='answerImage/%id/', blank=True, null=True)
#    answer  = models.ForeignKey(answer, related_name="images", on_delete=models.CASCADE)